﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="InquiryRecord.aspx.cs" Inherits="House客户端.InquiryRecord" %>

<!DOCTYPE html>
<html>
<head runat="server">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>询价页面</title>
    <link href="jquery-easyui-1.5.2/themes/default/easyui.css" rel="stylesheet" />
    <link href="easyui/css/wu.css" rel="stylesheet" />
    <link href="easyui/css/icon.css" rel="stylesheet" />
</head>
<body>
    <a class="easyui-linkbutton" id="inquiry" onclick="AddInquiry()">新增询价</a>
    <div style="width: 800px; height: 300px;">
        <table id="list">
        </table>
    </div>
    <div id="dlg" class="easyui-dialog" style="width: 800px; height: 300px; padding: 10px 20px; text-align: center" closed="true" buttons="#dlg-buttons">
        <form id="fm" method="post" action="">
            <table>
                <tr>
                    <td>项目号：</td>
                    <td style="padding-left: 50px;">
                        <input class="easyui-textbox" value="" id="ProjectNumber" type="text" style="width: 500px;" readonly="true" />
                    </td>
                </tr>
                <tr>
                    <td>建议评估单价(元/㎡)：</td>
                    <td style="padding-left: 50px;">
                        <input class="easyui-textbox" id="price" type="text" style="width: 500px;" data-options="required:true" />
                        <span id="sp1" style="color: red"></span>
                    </td>
                </tr>
                <tr>
                    <td>询价内容及其他：</td>
                    <td style="padding-left: 50px;">
                        <textarea id="message" style="height: 60px; width: 500px;" placeholder="说点什么...最少输入10个字"></textarea>
                        <span id="sp2" style="color: red"></span></td>
                </tr>
            </table>
            <a href="javascript:void(0)" class="easyui-linkbutton" onclick="add()">提交</a>
            <input type="hidden" name="action" id="hidtype" />
            <input type="hidden" name="roles_Id" id="Nameid" />
        </form>
    </div>
    <script src="jquery-easyui-1.5.2/jquery.min.js"></script>
    <script src="jquery-easyui-1.5.2/jquery.easyui.min.js"></script>
    <script src="jquery-easyui-1.5.2/locale/easyui-lang-zh_CN.js"></script>
    <script src="jquery-easyui-1.5.2/easyloader.js"></script>
    <script src="jquery-easyui-1.5.2/jquery.params.js"></script>
    <script src="jquery-easyui-1.5.2/Common.js"></script>
    <script type="text/javascript">
        $(function () {
            //绑定数据
            $('#list').datagrid({
                columns: [[
                 { field: 'ProjectNumber', title: '项目号', width: 100 },
                 { field: 'Inquiry_UnitPrice', title: '建议评估单价', width: 100, },
                 { field: 'Inquiry_Content', title: '询问内容及其他', width: 100, },
                 { field: 'Inquiry_Time', title: '询问时间', width: 150 },
                ]]
            });
            $.ajax({
                type: "get",
                url: WebApiURL + "api/Prospecting/GetEAInquiry",
                success: function (data) {
                    data = eval(data);
                    $("#list").datagrid("loadData", data);
                }
            });
        });
        //弹出框
        function AddInquiry() {
            $("#ProjectNumber").textbox("setValue", $.query.get("ProjectNumber"));
            $("#dlg").dialog("open").dialog('setTitle', '新增询价');
        }
        function add() {
            var ProjectNumber = $.query.get("ProjectNumber");//项目号
            var price = document.getElementById("price").value;
            var countent = $("#message").val();
            if (price == "" || price == null) {
                $("#sp1").html("不能为空"); return
            } else {

                $("#sp1").html("");
            }
            if (countent == "" || countent == null) {
                $("#sp2").html("不能为空"); return
            } else {

                $("#sp2").html("");
            }
            $.ajax({
                type: "post", //要用post方式                 
                url: WebApiURL + "api/Values/AddInquiry",//方法所在页面和方法名
                data: {
                    projectNumber: ProjectNumber,
                    inquiry_UnitPrice: price,
                    inquiry_Content: countent
                },
                success: function (result) {
                    if (result > 0) {
                        $.messager.alert("提示信息", "保存成功！");
                        location.href = "ProspectingList.aspx";
                    }
                    else
                        $.messager.alert("提示信息", "保存失败！");
                }
            });
        }
    </script>
</body>
</html>
